import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
// import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编码',
    align:"center",
    sorter: true,
    width: '100px',
    dataIndex: 'documentTypeCode'
   },
   {
    title: '单据名称',
    align:"center",
    sorter: true,
    dataIndex: 'documentTypeName'
   },
   {
    title: '实体名称',
    align:"center",
    sorter: true,
    dataIndex: 'entityName'
   },
  //  {
  //   title: '实体唯一值',
  //   align:"center",
  //   dataIndex: 'entityUniqueValue'
  //  },
   {
    title: '业务类型',
    align:"center",
    sorter: true,
    width: '100px',
    dataIndex: 'businessType',
    customRender: ({ text }) => render.renderDict(text, 'document_business_type')
   },
   {
    title: '确认方式',
    align:"center",
    sorter: true,
    width: '100px',
    dataIndex: 'confirmationMode',
    customRender: ({ text }) => render.renderDict(text, 'document_confirmation_mode')
   },
   {
    title: '审批流程',
    align:"center",
    dataIndex: 'approvalProcessName'
   },
  //  {
  //   title: '审批流程id',
  //   align:"center",
  //   dataIndex: 'approvalProcessId'
  //  },
   {
    title: '编码方式',
    align:"center",
    sorter: true,
    width: '100px',
    dataIndex: 'codingScheme',
    customRender: ({ text }) => render.renderDict(text, 'document_coding_scheme')
   },
  //  {
  //   title: '编码规则id',
  //   align:"center",
  //   dataIndex: 'codingRuleId'
  //  },
   {
    title: '编码规则',
    align:"center",
    width: '100px',
    dataIndex: 'codingRuleName'
   },
   {
    title: '第三方编码',
    align:"center",
    width: '110px',
    dataIndex: 'thirdPartyCode'
   },
   {
    title: '是否默认单据类型',
    align:"center",
    sorter: true,
    dataIndex: 'defaultType',
    customRender: ({ text }) => render.renderDict(text, 'yn')
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	// {
  //     label: "业务类型",
  //     field: 'businessType',
  //     component: 'JDictSelectTag',
  //     componentProps:{
  //         dictCode:"document_business_type"
  //     },
  //     colProps: {span: 6},
 	// },
	// {
  //     label: "确认方式",
  //     field: 'confirmationMode',
  //     component: 'JDictSelectTag',
  //     componentProps:{
  //         dictCode:"document_confirmation_mode"
  //     },
  //     colProps: {span: 6},
 	// },
	// {
  //     label: "编码方式",
  //     field: 'codingScheme',
  //     component: 'JDictSelectTag',
  //     componentProps:{
  //         dictCode:"document_coding_scheme	"
  //     },
  //     colProps: {span: 6},
 	// },
   {
       label: "单据编号",
       field: 'documentTypeCode',
       component: 'Input',
       colProps: {span: 6},
    },
    {
        label: "单据名称",
        field: 'documentTypeName',
        component: 'Input',
        colProps: {span: 6},
     },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'documentTypeCode',
    component: 'Input',
    dynamicRules: () => [{ required: true, message: '请输入编码!'}]
  },
  {
    label: '单据名称',
    field: 'documentTypeName',
    component: 'Input',
    dynamicRules: () => [{ required: true, message: '请输入单据名称!'}]
  },
  {
    label: '实体id',
    field: 'entityId',
    component: 'Input',
    show:false
  },
  {
    label: '实体表名',
    field: 'tableName',
    component: 'Input',
    show:false
  },
  {
    label: '实体名称',
    field: 'entityName',
    component: 'Input',
    slot:'entitySlot',
    dynamicRules: () => [{ required: true, message: '请选择实体名称!'}]
  },
  // {
  //   label: '实体唯一值',
  //   field: 'entityUniqueValue',
  //   component: 'Input',
  // },
  {
    label: '业务类型',
    field: 'businessType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"document_business_type",
        stringToNumber: true,
     },
  },
  {
    label: '确认方式',
    field: 'confirmationMode',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"document_confirmation_mode",
        stringToNumber: true,
     },
  },
  {
    label: '审批流程',
    field: 'approvalProcessName',
    component: 'Input',
  },
  {
    label: '审批流程id',
    field: 'approvalProcessId',
    component: 'Input',
    show:false
  },
  {
    label: '编码方式',
    field: 'codingScheme',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"document_coding_scheme",
        stringToNumber: true,
     },
  },
  {
    label: '编码规则id',
    field: 'codingRuleId',
    component: 'Input',
    show: false
  },
  {
    label: '编码规则',
    field: 'codingRuleName',
    component: 'Input',
    slot: 'customSlot'
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
  {
    label: '是否默认单据类型',
    field: 'defaultType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn",
        stringToNumber: true,
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}